smartbuck8 2.2.0
Loading...
Searching...
No Matches
smartbuck8.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef SMARTBUCK8_H
29#define SMARTBUCK8_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
58
63
68
73#define SMARTBUCK8_REG_VOUT 0x01
74#define SMARTBUCK8_REG_CONTROL 0x03
75#define SMARTBUCK8_REG_STATUS 0x05
76 // smartbuck8_reg
78
83
88
93#define SMARTBUCK8_CONTROL_RESET 0x80
94#define SMARTBUCK8_CONTROL_EN_FPWM_ON_CHANGE 0x40
95#define SMARTBUCK8_CONTROL_SOFT_EN 0x20
96#define SMARTBUCK8_CONTROL_EN_FPWM 0x10
97#define SMARTBUCK8_CONTROL_EN_OUT_DISCHARGE 0x08
98#define SMARTBUCK8_CONTROL_EN_HICCUP 0x04
99#define SMARTBUCK8_CONTROL_V_RAMP_SPEED_0_25US 0x00
100#define SMARTBUCK8_CONTROL_V_RAMP_SPEED_0_5US 0x01
101#define SMARTBUCK8_CONTROL_V_RAMP_SPEED_1US 0x02
102#define SMARTBUCK8_CONTROL_V_RAMP_SPEED_5US 0x03
103#define SMARTBUCK8_CONTROL_V_RAMP_SPEED_MASK 0x03
104
109#define SMARTBUCK8_STATUS_THERMAL_WARNING 0x10
110#define SMARTBUCK8_STATUS_HICCUP 0x08
111#define SMARTBUCK8_STATUS_UVLO 0x01
112
117#define SMARTBUCK8_VOUT_MV_MIN 400
118#define SMARTBUCK8_VOUT_MV_MAX 1675
119#define SMARTBUCK8_VOUT_MV_STEP_5MV 5
120
126#define SMARTBUCK8_DEVICE_ADDRESS 0x42
127 // smartbuck8_set
129
134
139
144#define SMARTBUCK8_MAP_MIKROBUS( cfg, mikrobus ) \
145 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
146 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
147 cfg.pon = MIKROBUS( mikrobus, MIKROBUS_RST ); \
148 cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
149 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
150 // smartbuck8_map // smartbuck8
153
158typedef struct
159{
160 // Output pins
161 digital_out_t pon;
162 digital_out_t en;
163
164 // Input pins
165 digital_in_t pg;
166
167 // Modules
168 i2c_master_t i2c;
169
170 // I2C slave address
172
174
179typedef struct
180{
181 pin_name_t scl;
182 pin_name_t sda;
183
184 pin_name_t pon;
185 pin_name_t en;
186 pin_name_t pg;
187
188 uint32_t i2c_speed;
189 uint8_t i2c_address;
190
192
203
209
220
235
249
262err_t smartbuck8_write_reg ( smartbuck8_t *ctx, uint8_t reg, uint8_t data_in );
263
276err_t smartbuck8_read_reg ( smartbuck8_t *ctx, uint8_t reg, uint8_t *data_out );
277
287
297
307
317
327
338err_t smartbuck8_read_status ( smartbuck8_t *ctx, uint8_t *status );
339
350err_t smartbuck8_set_control ( smartbuck8_t *ctx, uint8_t control );
351
363err_t smartbuck8_set_vout ( smartbuck8_t *ctx, uint16_t vout_mv );
364
365#ifdef __cplusplus
366}
367#endif
368#endif // SMARTBUCK8_H
369 // smartbuck8
371
372// ------------------------------------------------------------------------ END
err_t smartbuck8_write_reg(smartbuck8_t *ctx, uint8_t reg, uint8_t data_in)
Smart Buck 8 write register function.
void smartbuck8_disable_power(smartbuck8_t *ctx)
Smart Buck 8 disable power function.
err_t smartbuck8_set_control(smartbuck8_t *ctx, uint8_t control)
Smart Buck 8 set control register function.
void smartbuck8_cfg_setup(smartbuck8_cfg_t *cfg)
Smart Buck 8 configuration object setup function.
void smartbuck8_enable_power(smartbuck8_t *ctx)
Smart Buck 8 enable power function.
void smartbuck8_enable_device(smartbuck8_t *ctx)
Smart Buck 8 enable device function.
err_t smartbuck8_default_cfg(smartbuck8_t *ctx)
Smart Buck 8 default configuration function.
err_t smartbuck8_init(smartbuck8_t *ctx, smartbuck8_cfg_t *cfg)
Smart Buck 8 initialization function.
err_t smartbuck8_read_status(smartbuck8_t *ctx, uint8_t *status)
Smart Buck 8 read status register function.
void smartbuck8_disable_device(smartbuck8_t *ctx)
Smart Buck 8 disable device function.
err_t smartbuck8_set_vout(smartbuck8_t *ctx, uint16_t vout_mv)
Smart Buck 8 set output voltage function.
uint8_t smartbuck8_get_pg_pin(smartbuck8_t *ctx)
Smart Buck 8 get power-good pin function.
err_t smartbuck8_read_reg(smartbuck8_t *ctx, uint8_t reg, uint8_t *data_out)
Smart Buck 8 read register function.
smartbuck8_return_value_t
Smart Buck 8 Click return value data.
Definition smartbuck8.h:198
@ SMARTBUCK8_ERROR
Definition smartbuck8.h:200
@ SMARTBUCK8_OK
Definition smartbuck8.h:199
Smart Buck 8 Click configuration object.
Definition smartbuck8.h:180
uint32_t i2c_speed
Definition smartbuck8.h:188
pin_name_t pon
Definition smartbuck8.h:184
pin_name_t scl
Definition smartbuck8.h:181
pin_name_t en
Definition smartbuck8.h:185
pin_name_t sda
Definition smartbuck8.h:182
pin_name_t pg
Definition smartbuck8.h:186
uint8_t i2c_address
Definition smartbuck8.h:189
Smart Buck 8 Click context object.
Definition smartbuck8.h:159
digital_out_t pon
Definition smartbuck8.h:161
i2c_master_t i2c
Definition smartbuck8.h:168
digital_out_t en
Definition smartbuck8.h:162
uint8_t slave_address
Definition smartbuck8.h:171
digital_in_t pg
Definition smartbuck8.h:165